<template>
  <div>
    <el-table
      :data="tableData"
      :span-method="objectSpanMethod"
      border
      style="width: 100%; margin-top: 20px"
    >
      <el-table-column prop="type" label="KPI指标" width="180"></el-table-column>
      <el-table-column prop="name" label="关系"> </el-table-column>
      <el-table-column prop="amount1" label="编号"> </el-table-column>
      <el-table-column prop="amount2" label="指标值"> </el-table-column>
      <el-table-column prop="amount3" label="换算系数"> </el-table-column>
      <el-table-column prop="amount3" label="状态"> </el-table-column>
      <el-table-column prop="amount3" label="操作"> </el-table-column>
    </el-table>
  </div>
</template>

<script>
import comTable from "@/wss/views/comTest/weile/comTable/comTable.vue";
export default {
  name: "Index",
  components: {
    comTable,
  },
  data() {
    return {
      tableData: [
        {
          type:"231231231",
          id: "12987122",
          name: "王小虎",
          amount1: "234",
          amount2: "3.2",
          amount3: 10,
        },
        {
          type:"231231231",
          id: "12987123",
          name: "王小虎",
          amount1: "165",
          amount2: "4.43",
          amount3: 12,
        },
        {
          type:"231kasjdfkjs",
          id: "12987124",
          name: "王小虎",
          amount1: "324",
          amount2: "1.9",
          amount3: 9,
        },
        {
          type:"ashdfjasdfajs",
          id: "12987125",
          name: "王小虎",
          amount1: "621",
          amount2: "2.2",
          amount3: 17,
        },
        {
          type:"hajsdhfkashdlfahsdjf",
          id: "12987126",
          name: "王小虎",
          amount1: "539",
          amount2: "4.1",
          amount3: 15,
        },
      ],
    };
  },

  mounted() {},

  methods: {
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 0) {//第 columnIndex 列需要合并
        if (rowIndex % 3 === 0) {//每 rowIndex % 2 开始合并，合并rowspan列，colspan格
          return {
            rowspan: 3,//合并3行
            colspan: 1,//合并1列
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0,
          };
        }
      }else if(columnIndex === 1){
        if (rowIndex % 3 === 0) {//每 rowIndex % 2 开始合并，合并rowspan列，colspan格
          return {
            rowspan: 3,//合并3行
            colspan: 1,//合并1列
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0,
          };
        }
      }else if(columnIndex === 5){
        if (rowIndex % 3 === 0) {//每 rowIndex % 2 开始合并，合并rowspan列，colspan格
          return {
            rowspan: 3,//合并3行
            colspan: 1,//合并1列
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0,
          };
        }
      }
    },
  },
};
</script>

<style lang="scss" scoped>
</style>